<?php
defined('APPROOT') || define('APPROOT', dirname(dirname(__FILE__)));
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', true);

set_include_path( APPROOT
                . PATH_SEPARATOR . APPROOT . '/vendor/' //第三方库
                . PATH_SEPARATOR . APPROOT . '/lib/'//自己编写的库
                . PATH_SEPARATOR . APPROOT . '/app/models/'//模型库
                . get_include_path()//系统支持库
               );

require_once 'Zend/Loader.php';
spl_autoload_register(array('Zend_Loader', 'autoload'));

$config = new Zend_Config_Ini(APPROOT . '/app/config.php', null);
Zend_Registry::set('config', $config);
// Set timezone
date_default_timezone_set($config->General->timezone);

// Connect to database
$db = Zend_Db::factory($config->Database->adapter, $config->Database->asArray());
$db->query("SET NAMES {$config->Database->charset}");
Zend_Db_Table::setDefaultAdapter($db);
Zend_Registry::set('db', $db);

$front = Zend_Controller_Front::getInstance();
//$front->addControllerDirectory(APPROOT . '/app/controllers');
$front->setControllerDirectory(array(
'default'   => APPROOT . '/app/controllers',
'admin'     => APPROOT . '/app/controllers/admin/controllers',
));
$front->throwExceptions(true);
$front->dispatch();


$response = $front->getResponse();
/* @var $response Zend_Controller_Response_Abstract */
if ($response->isException()) {
	echo "ERROR!";
}else
{

}
